#coding:utf-8

from ftplib import FTP
import os
import os.path
import re
import shutil


del_files = ['bin', '.settings', '.project', '.classpath', 'target', 'logs','gradle','build', '.gradle']


def list_dirs_files(dirpath, depth=0):
    if depth==3:
       return

    for filename in os.listdir(dirpath):
        sub_path = dirpath + '/' + filename
        isdir = os.path.isdir(sub_path)
        # print(sub_path + " " +str())
        if filename in del_files:
           print("删除文件： " + sub_path)
           if isdir:
               shutil.rmtree(sub_path)
           else:
               os.remove(sub_path)
        elif os.path.isdir(sub_path):
            list_dirs_files(sub_path, depth+1)

def main():
    list_dirs_files(".")


if __name__ == '__main__':
    main()
